#ifndef _LOG_TESTS_H_
#define _LOG_TESTS_H_
#include "gtest/gtest.h"
#include "testLogWriter.h"
#include <boost/shared_ptr.hpp>

class LogTestFixtureTest : public ::testing::Test
{
public:
	void SetUp(){}
	void TearDown(){}
	/*
	const std::string TEST_APP;
	CTestLogWriter* m_tlw;

	void SetUp()
	{
		// Setting up the logger
		glog::CGlobalLog& m_log = glog::CGlobalLog::getSingleton();
		m_log.addAppender(TEST_APP);
		m_log.addListener(m_tlw, TEST_APP);
		m_log.setMiniumLevel(glog::LOGLEVEL_DEBUG);
	}
	void TearDown()
	{
		// Tearing down the log.
		glog::CGlobalLog& m_log = glog::CGlobalLog::getSingleton();
		m_log.processMessages();
	}

	LogTestFixtureTest()
		:TEST_APP("[TEST_LOG]")
	{
		glog::CGlobalLog::initSingleton();
		m_tlw = new CTestLogWriter(false);
	}

	virtual ~LogTestFixtureTest(){

	}
	*/
};

TEST_F(LogTestFixtureTest, GLOG_destroys_correctly_when_a_listener_is_suscribed_to_2_or_more_queues)
{
	glog::CGlobalLog::initSingleton();
	glog::CGlobalLog* m_log = &glog::CGlobalLog::getSingleton();
	m_log->setMiniumLevel(glog::LOGLEVEL_DEBUG);
	// add appenders
	m_log->addAppender("MY_APPENDER");
	m_log->addAppender("MY_APPENDER001");
	m_log->addAppender("MY_APPENDER002");

	// suscribing listener to 2 appenders
	//CTestLogWriter* m_tlw = new CTestLogWriter(false);
	boost::shared_ptr<glog::IListener> sp(new CTestLogWriter(false));
	m_log->addListener(sp,"MY_APPENDER001");
	m_log->addListener(sp,"MY_APPENDER002");

	//add messages to both appenders
	m_log->addMessage("MY_APPENDER002",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #10");
	m_log->addMessage("MY_APPENDER002",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #11");
	m_log->addMessage("MY_APPENDER002",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #12");
	m_log->addMessage("MY_APPENDER002",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #13");
	m_log->addMessage("MY_APPENDER001",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #14");
	m_log->addMessage("MY_APPENDER001",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #15");
	m_log->addMessage("MY_APPENDER001",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #16");
	m_log->addMessage("MY_APPENDER001",glog::LOGLEVEL_INFO,"Esto es una linea de prueba #17");

	// destroy singleton calls the globalLog destructor
	ASSERT_NO_FATAL_FAILURE(glog::CGlobalLog::destroySingleton());
}
#endif //_LOG_TESTS_H_
